// import { request } from "../utils/request";
import fly from "../utils/request";
import serviceUrl from "../utils/baseUrl";
// export function userLogin(user) {
//   let params = {
//     url: "Auth/login",
//     method: "POST",
//     data: user,
//   };
//   return request(params);
// }

// 用户登录
export const userLogin = (params, data) => {
  return fly
    .post("/api/Auth/login", data, {
      params: params,
    })
    .then((res) => res.data);
};
export const uploadFile = (uploadFile) => {
  let _url = serviceUrl.API;
  let token = wx.getStorageSync("token");
  return new Promise((resolve, reject) => {
    wx.uploadFile({
      url: _url + "/api/File/upload",
      header: {
        Authorization: `Bearer ${token}`,
      },
      filePath: uploadFile,
      name: "file", //上传的所需字段，后端提供
      success: (res) => {
        // console.log("resdata=", res);
        // 上传完成操作
        // const data = JSON.parse(res.data);

        const url = res.data;
        resolve({
          url: url,
        });
      },
      fail: (err) => {
        //上传失败：修改pedding为reject
        reject(err);
      },
    });
  });
};
